<?php if (!defined('SERVER_ROOT')) exit('No direct script access allowed');

class giaotrinh_Controller extends Controller {

    function __construct()
    {
        parent::__construct('giangvien', 'giaotrinh');
        $this->check_login();
        $this->view->template->menu_html =$this->CREATE_MENU();
        $this->view->template->nhacviec_html =$this->CREATE_NHAC_VIEC(); 
        $this->CHECK_QUYEN('giangvien', 'giaotrinh');
    }

    function main(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->dsp_all_giaotrinh();
    }

    function dsp_all_giaotrinh(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $VIEW_DATA['arr_all_giaotrinh']= $this->model->qry_all_giaotrinh();
        $this->view->render('dsp_all_giaotrinh', $VIEW_DATA);
    }
    public function dsp_single_giaotrinh($TEN_GIAO_TRINH){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $TEN_GIAO_TRINH = replace_bad_char($TEN_GIAO_TRINH);
        $VIEW_DATA['arr_all_loaigiaotrinh'] = $this->model->SELECT_LOAIGIAOTRINH_nothing();
        $VIEW_DATA['arr_single_giaotrinh'] = $this->model->qry_single_giaotrinh($TEN_GIAO_TRINH);
        $this->view->render('dsp_single_giaotrinh', $VIEW_DATA);
    }
    public function update_giaotrinh()
    {
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_giaotrinh';
        $this->model->update_giaotrinh();
    }
    public function delete_giaotrinh(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_giaotrinh';
        $this->model->delete_giaotrinh();
    }
}